草庐IT

windows - Git 找不到别名命令

全部标签

ruby-on-rails - Ruby 1.9.3 -> 2.0 别名方法和扩展

我正在尝试将Ruby1.9.3应用程序升级到2.0,除了一个小问题外,一切似乎都很顺利。我写了一个模块,我将其包含在我的模型中以覆盖activerecorddestroy。它将现有的destroy方法别名为destroy!,然后覆盖destroy以更改记录上的deleted_at时间戳。仅当我升级到ruby​​2.0时,destroy!不再破坏记录,但其行为就像我的新覆盖方法一样。知道为什么会这样吗?下面是更相关的代码部分。完整要点here.defself.included(base)base.class_evaldoalias_method:destroy!,:destroyalia

ruby - 在 Windows 7 上运行 Jekyll

我在Windows7上运行Jekyll时遇到问题。当我运行时jekyll出现以下错误C:\temp\jekyll\kouphax.github.com>jekyllConfigurationfromC:/temp/jekyll/kouphax.github.com/_config.ymlBuildingsite:C:/temp/jekyll/kouphax.github.com->C:/temp/jekyll/kouphax.github.com/_siteunit-testingYouaremissingalibraryrequiredforTextile.Pleaserun:$[s

ruby - block 看不到方法( Chef 资源)

假设我们有两个资源:template'template1'doowner'root'group'root'endtemplate'template2'doowner'root'group'root'end我想在资源中重用代码。但是,如果我在配方中定义了一个过程,您会得到owner、group等的NoMethodError。为什么会这样?词法范围没有什么不同,是吗?因此,我必须使用self.instance_eval&common_cfg。common_cfg=Proc.new{owner'root'group'root'}template'template1'docommon_cfg.

ruby - 猴子修补 float 中缀运算符产生意想不到的结果

重新定义Float#/似乎没有效果:classFloatdef/(other)"magic!"endendputs10.0/2.0#=>5.0但是当另一个中缀运算符Float#*被重新定义时,Float#/突然采用了新的定义:classFloatdef/(other)"magic!"enddef*(other)"spooky"endendputs10.0/2.0#=>"magic!"我很想知道是否有人可以解释这种行为的来源,以及其他人是否得到相同的结果。ruby:ruby2.0.0p353(2013-11-22)[x64-mingw32]要快速确认错误,请运行thisscript.

ruby - 编写一个 ruby​​ 命令行应用程序;最好的方法是做到这一点?

我有一个正在开发的命令行Ruby应用程序,我想允许它的用户提供将在部分过程中作为过滤器运行的代码。基本上,应用程序是这样做的:读入一些数据如果指定了过滤器,则使用它来过滤数据处理数据我希望过滤过程(第2步)尽可能灵活。我的想法是,用户可以提供一个Ruby文件,该文件设置一个已知常量以指向实现我定义的接口(interface)的对象,例如:#user'sfilterclassMyFilterdefdo_filter(array_to_filter)filtered_array=Array.new#domyfilteringonarray_to_filterfiltered_arrayen

ruby-on-rails - 如何在模块中为类方法起别名?

我正在使用Rubyv1.9.2和RubyonRailsv3.2.2gem。我有以下模块moduleMyModuleextendActiveSupport::Concernincludeddodefself.my_method(arg1,arg2)...endendend我想为类方法my_method起别名。因此,我声明了以下(不工作)代码:moduleMyModuleextendActiveSupport::Concernincludeddodefself.my_method(arg1,arg2)...end#Note:thefollowingcodedoesn'twork(itrai

ruby - 当 shelled-out 命令返回非零退出代码时,如何让 Ruby 脚本失败?

在Ruby脚本中,有variousways调用系统命令/命令行反引号:`commandarg1arg2`分隔形式,例如%x(commandarg1arg2)(可用其他分隔符)Kernel#system方法:system('commandarg1arg2')Kernel#exec方法:exec('commandarg1arg2')如果我希望Ruby脚本在调用的命令失败时失败(有异常)(具有非零退出代码),我可以检查特殊变量中的退出代码$?对于前两个变体:`commandarg1arg2`failunless$?==0或%x,commandarg1arg2,failunless$?==0如

ruby - 是否有任何命令可以使用 vim 转到 Ruby block 的末尾(或开始)

有没有办法使用vim结束Rubyblock?例如moduleSomeModule#defsome_methodendend我想用一个命令从光标所在的位置移动到block的末尾,这可能吗?我读过thisdocumentation,但它似乎不适用于.rb文件,我在某些地方读到它只适用于C(虽然还没有尝试过)。提前致谢。 最佳答案 rubyforge好像有官方包对此有一些支持:TheRubyftpluginnowincludesRubyspecificimplementationsforthe[[,]],[],][,[m,]m,[M,an

ruby-on-rails - rails 上的 ruby 。 bundler 。 cucumber 。 rake 中止!命令失败,状态为 (1)

我在Rails3中使用Bundler和Cucumber时遇到问题。当我运行$rakecucumber时,我得到以下输出:bundleexec/usr/local/bin/ruby-I"/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/lib:lib""/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/bin/cucumber"--profiledefault(in/home//practice/rails/blog)Usingthedefaultprofile...UUUU1scen

ruby-on-rails - Rails 3 Cli 执行命令真的很慢吗?

有人知道为什么我的rails3.0.7cli这么慢吗?当我运行railss或railsg时,他大约需要5秒才能真正执行命令...有什么建议吗?谢谢 最佳答案 更新:我正在将我的建议从rrails切换到rails-sh,因为前者支持REPL,而rrails不是用例。此外,当与ruby​​环境结合使用时,修补似乎确实可以提高性能变量,现在反射(reflect)在答案中。一个可能的原因可能是这个performancebuginruby每当在ruby​​代码中使用“require”时,它就会调用一些代码(更多详细信息here)。在使用Rai